<?php

class Bid_CategoryController extends Bid_Library_Controller_Action
{
    protected $_limit = 4;
    protected $_page = 1;
    protected $_wheres = array();
    protected $_orders = array();
    protected $_total;
    protected $_items;
    
    public function init()
    {
        parent::init();
       
        $id = $this->_getParam('id', 0);
        if($id == 0 || !is_numeric($id)) $this->_redirect('/');
        $subid = $this->_getParam('subid', 0);
        if($subid != 0 && !is_numeric($subid)) $this->_redirect('/');
        
        $this->_model = new Model_BidItem();
        $this->_page = $this->_getParam('page', 1);
        if($this->_getParam('action') == 'grid') $this->_limit = 9;
        
        $this->_wheres['category_id = ?'] = $id;
        $this->_orders[] = 'reserve_price ASC';
        
        $this->_items = $this->_model->getArray($this->_page, $this->_limit, $this->_wheres, $this->_orders);
        $this->view->assign('items', $this->_items);
        
        $this->_total = $this->_model->getTotalEntries($this->_wheres);
        $this->view->assign('item_per_page', $this->_limit);
        $this->view->assign('total', $this->_total);
        $this->view->assign(
            'pagination_config', array(
                'total_items' => $this->_total,
                'items_per_page' => $this->_limit,
                'style' => 'bidbiz'
            )
        );
        
        $this->view->assign('category_id', $id);
    }

    public function listAction() {
    }
    
    public function gridAction() {
    }
}